package net.sharpf2.api.info;

import net.sharpf2.api.Globals;
import net.sharpf2.api.Methods;
import net.sharpf2.api.game.Interfaces;

/**
 *
 * @author Sam Smekens
 */
public class Summoning {

    
    public static int getSummoningPoints(){
        if (Interfaces.isInterfaceValid(747) && Globals.CLIENT.getGamestate() == 11) {
            return (int)Integer.parseInt(Interfaces.get(747, 5).getContent().getText());
        }
        return -1;
    }
    
    /**
     * Gets the current left-click option
     * @return int setting
     * @see Constants
     */
    public static int getLeftClickOption(){
        if (Interfaces.isInterfaceValid(747) && Globals.CLIENT.getGamestate() == 11) {
            return Globals.CLIENT.getSettings().getData()[Constants.LEFT_CLICK_OPTION];
        }
        return -1;
    }
    
    /**
     * Sets the left-click option
     * @param i Option which should be selected/activated. Use Constants
     */
    public static void setLeftClickOption(int i){
        if(Interfaces.isInterfaceValid(Constants.SUMM_LEFT_OPTION)){
            if(Interfaces.get(Constants.SUMM_LEFT_OPTION, Constants.LEFT_CLICK_OPTIONS[i]).getContent().getTextureId() != 2035){
                Interfaces.get(Constants.SUMM_LEFT_OPTION, Constants.LEFT_CLICK_OPTIONS[i]).getActions().click();
                Methods.sleep(350);
                Interfaces.get(Constants.SUMM_LEFT_OPTION, Constants.SUMM_LEFT_CLICK_CONFIRM);
            }else{
                Interfaces.get(Constants.SUMM_LEFT_OPTION, Constants.SUMM_LEFT_CLICK_CONFIRM);
            }
        }else if(Interfaces.isInterfaceValid(747)){
            Interfaces.get(747, 7).getActions().click("(Select left-click option|Wähl Linksklick-Option|Sélectionner l'option clic gauche)");
        }
    }
    
    /**
     * Clicks the 'left-click option'
     */
    public static void useLeftClickOption(){
        if(Interfaces.isInterfaceValid(747)){
            Interfaces.get(747, 2).getActions().click();
        }
    }
    
    public static class Constants{
        public static final int LEFT_CLICK_OPTION = 1493;
        public static final int SUMM_LEFT_OPTION = 880;
        public static final int SUMM_LEFT_CLICK_CONFIRM = 6;
        
        private static final int LEFT_CLICK_OPTIONS[] = {7, 9, 11, 13, 15, 17, 19, 25};
        
        public static final int SETTING_FOLLOWER_DETAILS = 0;
        public static final int SETTING_SPECIAL_MOVE = 1;
        public static final int SETTING_ATTACK = 2;
        public static final int SETTING_CALL_FOLLOWER = 3;
        public static final int SETTING_DISMISS_FOLLOWER = 4;
        public static final int SETTING_TAKE_BOB = 5;
        public static final int SETTING_RENEW_FAMILIAR = 6;
        public static final int SETTING_INTERACT = 7;        
    }
}